//
//  AppDelegate.h
//  BlueTDevice
//
//  Created by MingmingSun on 16/7/17.
//  Copyright © 2016年 Sunmingming. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVOSCloud.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <AFNetworking/AFNetworking.h>
#import <BabyBluetooth/BabyBluetooth.h>
#import "RootViewController.h"
#import <LKDBHelper.h>
#import "SpUserItem.h"

@protocol VCBlueTDelegate<NSObject>
@optional
- (void)BlueTSucceed:(NSString*)aSucc;
- (void)BlueTFailed:(NSString*)aSucc;
@end

#define channelOnPeropheralView @"peripheralView"
#define channelOnCharacteristicView @"CharacteristicView"

#define MoshiUUID @"2A38"
#define DangweiUUID @"2A39"
#define KaiguanUUID @"2A3A"
#define JiechuUUID @"2A3B"
#define DianliangUUID @"2A1A"

@interface AppDelegate : UIResponder <UIApplicationDelegate>{
    //    UITableView *tableView;
    NSMutableArray *peripherals;
    NSMutableArray *peripheralsAD;
    BabyBluetooth *baby;
}

@property (strong, nonatomic) UIWindow *window;
//全局数据库指针
@property(nonatomic,assign) int nowLevel;
@property(nonatomic,assign) int hasBoughtLevel;

@property(strong,nonatomic) NSMutableArray *peripherals;
@property(strong,nonatomic) NSMutableArray *peripheralsAD;
@property(strong,nonatomic) BabyBluetooth *baby;
@property(strong,nonatomic) NSMutableArray *services;
@property(strong,nonatomic) CBPeripheral *currPeripheral;

//2A38 0x01-0x04
@property(strong,nonatomic) CBCharacteristic *MoshiChatic;
//2A39 0x01-0x08
@property(strong,nonatomic) CBCharacteristic *DangweiChatic;
//2A3A 0x04开始 0x05停止
@property(strong,nonatomic) CBCharacteristic *KaiguanChatic;
//2A3B 0x01接触 0x00未接触
@property(strong,nonatomic) CBCharacteristic *JiechuChatic;
//2A1A 0x00-0x63
@property(strong,nonatomic) CBCharacteristic *DianliangChatic;

@property(nonatomic,assign) int finishBlock;

@property(strong,nonatomic) LKDBHelper* globalDBManager;
@property(nonatomic,strong) SpUserItem *myUserItem;

@property(nonatomic,strong) AFHTTPSessionManager *netSession;

@property(nonatomic,assign) id<VCBlueTDelegate> myBlueTDelegate;

@property(nonatomic,strong) RootViewController *vc;

-(void)startToScanBlueT:(NSString*)aIAP;
-(void)stopScanBlueT:(NSString*)aIAP;
-(void)loadDevice:(NSInteger)aIndex;

-(void)writeToChatic:(NSString*)aChatic withValue:(NSData*)aValue;

-(void)dismissLoginWindow;
-(void)showLoginWindow;

@end

